﻿using System.Collections.Generic;
using BusinessBingo.Model;

namespace BusinessBingo.Web.Models.ViewModels
{
    public static class ViewModelConverter
    {
        public static BingoSetViewModel GetBingoSetViewModel(BingoSet bingoSet)
        {
            BingoSetViewModel model = new BingoSetViewModel();
            model.WordPositionViewModels = new List<WordPositionViewModel>();

            model.Size = bingoSet.Size;
            model.Finished = bingoSet.IsFinished;
            model.UserId = bingoSet.UserId;
            foreach (WordPosition wordPosition in bingoSet.WordPositions)
            {
                WordPositionViewModel wordPositionViewModel = new WordPositionViewModel();
                wordPositionViewModel.WordId = wordPosition.Word.Id;
                wordPositionViewModel.WordName = wordPosition.Word.Value;
                wordPositionViewModel.Checked = wordPosition.Checked;
                wordPositionViewModel.PositionX = wordPosition.PositionX;
                wordPositionViewModel.PositionY = wordPosition.PositionY;

                model.WordPositionViewModels.Add(wordPositionViewModel);
            }

            return model;
        }
    }
}